<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/index3.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-1.8.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/My97DatePicker/WdatePicker.js"></script>
</head>

<body>
${user}
<form action="./list" method="post">
    <input type="hidden" name="cur">
    类型:
    <select name="typeId" id="tt">
        <option value="0"></option>
    </select>
    品牌:
    <select name="brandId" id="bb">
        <option value="0"></option>
    </select><br>
    <input type="submit" value="搜索">
</form>
<table>
    <tr>
        <td>产品归属</td>
        <td>产品编号</td>
        <td>产品名称</td>
        <td>产品类型</td>
        <td>产品品牌</td>
        <td>产品图片</td>
        <td>产品型号</td>
        <td>产品规格</td>
        <td>产品单价</td>
    </tr>
    <<c:forEach items="${list}" var="li">
    <tr>
        <td>${li.garea}</td>
        <td>${li.gnum}</td>
        <td>${li.gname}</td>
        <td>${li.type.tname}</td>
        <td>${li.brand.bname}</td>
        <td>
            <img src="/pic/${li.img}" width="50px" height="50px">
        </td>
        <td>${li.gxing}</td>
        <td>${li.ggui}</td>
        <td>${li.price}</td>
    </tr>
</c:forEach>
</table>
<button onclick="page(${pp.pageNum==1?1:pp.pageNum-1})">上一页</button>
<c:forEach items="${pp.navigatepageNums}" var="d">
    <button onclick="page(${d})">${d}</button>
</c:forEach>
<button onclick="page(${pp.pageNum==pp.pages?pp.pages:pp.pageNum+1})">下一页</button>
<button onclick="zj()">增加</button>
<script>
    function zj() {
      location="./toadd";
    }
    $.post("typelist",function (obj) {
        for(var w of obj){
            $("#tt").append('<option value="'+w.tid+'">'+w.tname+'</option>')
        }
        $("#tt").val(${ov.typeId})
    },"json")

    $.post("brandlist",function (obj) {
        for(var w of obj){
            $("#bb").append('<option value="'+w.bid+'">'+w.bname+'</option>')
        }
        $("#bb").val(${ov.brandId});
    },"json")

    function page(cur) {
     $('[name="cur"]').val(cur);
     $('form').submit();
    }
</script>
</body>
</html>
